<template>
  <div id="app">
    <div class="back">
      <h1>3D 立体仓库系统</h1>
      <button v-if="currentView === 'cube'" @click="currentView = 'warehouse'">
        返回仓库场景
      </button>
    </div>

    <div class="rackFNum" v-if="currentView === 'cube'">
      <div class="form-group">
        <label>长 (列数):</label>
        <InputNumber v-model="newShelfConfig.columns" :min="1" :max="10" />
      </div>
      <div class="form-group">
        <label>高 (层数):</label>
        <InputNumber v-model="newShelfConfig.levels" :min="1" :max="10" />
      </div>
      <div class="form-group">
        <label>深 (货位深度):</label>
        <InputNumber v-model="newShelfConfig.depthLength" :min="0.5" :max="3" :step="0.1" />
      </div>
      <div class="button-group">
        <Button type="primary" @click="childe">生成货架</Button>
      </div>
    </div>

    <div class="scene-container">
      <WarehouseScene2 v-if="currentView === 'warehouse'" @warehouse-selected="currentView = 'cube'" />
      <CubeScene v-else ref="depot" :newShelfConfig="newShelfConfig" />
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import WarehouseScene from './components/WarehouseScene.vue'
import WarehouseScene2 from './components/WarehouseScene2.vue'

import CubeScene from './components/CubeScene.vue'
const currentView = ref('warehouse')

const newShelfConfig = reactive({
  columns: 3,
  levels: 4,
  depth: 1, // 深度方向货位数，默认为1
  depthLength: 0.5, // 每个货位的深度
  columnWidth: 0.5, // 每个货位的宽度
  levelHeight: 0.5, // 每层的高度
  pillarColor: 0x2196F3,
  shelfColor: 0x1976D2
});
const depot = ref(null)
const childe = () => {
  depot.value.startShelfPlacement()
}
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI';
  background: #87CEEB;
  color: #fff;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  background: #87CEEB;
  flex-direction: column;
}

.back {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);

  h1 {
    padding: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-right: 20px;
  }

}

.rackFNum {
  width: 100%;
  display: flex;
  align-items: flex-end;
  margin-right: auto;
  padding: 0 10px 10px 10px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.2);

  .form-group {
    margin-left: 10px;

    label {
      display: block;
      margin-bottom: 5px;
      font-weight: bold;
    }
  }

}


button {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0 10px;
}

button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.scene-container {
  flex: 1;
  width: 100%;
  position: relative;
}
</style>